﻿using AiXiu.BLL;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Web.UI;

namespace AiXiu.WebSite
{
    /// <summary>
    /// 好友列表
    /// </summary>
    public partial class Friends : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // 获取好友列表
                int userId = IdentityManager.ReadUser().Id;
                IFriendManager friendManager = new FriendManager();
                Dictionary<int, Friend> friendDictionary = friendManager.GetFriends(userId);
                // 绑定到页面
                this.rptFriends.DataSource = friendDictionary;
                this.rptFriends.DataBind();
            }
        }

        /// <summary>
        /// 显示日期或时间
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        protected string ShowDateOrTime(DateTime dateTime)
        {
            DateTime today = DateTime.Today.Date;
            if (dateTime.Date.Equals(today))
                // 如果是今天消息，则显示消息时间
                return dateTime.ToString("HH:mm");
            else
                // 如果不是今天消息，则显示日期
                return dateTime.ToString("MM:dd");
        }
    }
}